<!-- 
时间 : 2025.03.12:14.38.34
名称 : G_PageHomeHead
类型 : component
功能 : *
编码 : 村长有人偷包谷
 -->
<script setup>
import { ref } from 'vue'
import { Plus } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
const R = useRouter()
// const _g = Global()
const props = defineProps({
    Config: {
        type: Object,
        default: () => {
            return {
                dropdownList: [],
                showAdd: true,
                title: "委托单据管理",
                url: ''
            }
        }
    }
})

const emit = defineEmits(['O_AddSee', 'select'])

// 当前选中的标题
const D_HeadForm = ref(props.Config.title)
const D_HeadFormList = ref(props.Config.dropdownList || false)
const D_showAdd = ref(props.Config.showAdd)
const D_url = ref(props.Config.url)
// 下拉选择
const O_TaskType = (val) => {
    D_HeadForm.value = val
    emit('select', val)
}

// 新增
const O_Add = () => {
    if (D_url.value) {
        // _g._AddTab({
        //     title: `${D_HeadForm.value} - 新增`,
        //     url: props.Config.url
        // })
        R.push({
            path: D_url.value
        })
    } else {
        emit('O_AddSee', true)
    }
}
</script>

<template>
    <div class="tablehome_header">
        <div class="dropdown-wrapper">
            <el-dropdown>
                <span class="el-dropdown-link">
                    <h2 class="tablehome_title">
                        {{ D_HeadForm }}
                        <el-icon class="el-icon--right">
                            <arrow-down />
                        </el-icon>
                    </h2>
                </span>
                <template #dropdown v-if="D_HeadFormList.length">
                    <el-dropdown-menu class="dropdown-menu">
                        <el-dropdown-item v-for="(o, i) in D_HeadFormList" :key="i" @click="O_TaskType(o.name)">
                            {{ o.name }}
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
        <div v-if="D_showAdd">
            <div>
                <el-button type="primary" :icon="Plus" @click="O_Add">新 增</el-button>
            </div>
        </div>
    </div>
</template>

<style lang="less">
.tablehome_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
</style>
